import threading
import socket
import time
import pickle
import json


def client_tel():
	ip_port = ('127.0.0.1', 9999)



	s = socket.socket()     # 创建套接字

	s.connect(ip_port)      # 连接服务器

	while True:     # 通过一个死循环不断接收用户输入，并发送给服务器
	    # inp = input("请输入要发送的信息： ").strip()
	    # inp = "我是客户端"
	    send_dict = {'a':1, 'b':2}
	    send_json = json.dumps(send_dict)
	    #inp = pickle.dumps()


	    time.sleep(1)

	    s.sendall(send_json.encode())


	    server_reply = s.recv(1024).decode()

	    if server_reply == "exit":
	    	break
	    	print(server_reply)

	    print(server_reply)

	s.close()       # 关闭连接


def threadFunctionOne():
	while True:
		print("thread 1")
		time.sleep(2)
		


if __name__ == '__main__':
	thread_1 = threading.Thread(target=client_tel)
	thread_1.start()
	while True:
		print("main thread")
		time.sleep(1)

	thread_1.close()